/*
Date:20210503 0:14PM
key:想着那道验证是否对称二叉树的题目，从两个节点作为参数入手，然而好像错了。以根为中心交换左右节点即可。
 */
class Solution {
public:


    void invertTree2(TreeNode* root)
    {
        if(root==nullptr){return;}
        invertTree2(root->left);
        invertTree2(root->right);
        TreeNode* c=root->right;
        root->right=root->left;
        root->left=c;

    }
    TreeNode* invertTree(TreeNode* root) {
        if(root==nullptr){return nullptr;}
        invertTree2(root);
        return root;
    }
};